﻿@model ZSZ.DTO.PermissionDTO
@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<form id="formEdit">
    <input type="hidden" name="id" id="id" value="@Model.Id"/>
    名称：<input type="text" name="name" id="name" value="@Model.Name" />
    描述：<input type="text" name="description" id="description" value="@Model.Description" />
    <input type="button" value="保存" id="btnSave" />
</form>
@section FooterScript
{
    <script type="text/javascript">
        var saveAjax = function () {
            var formData = $("#formEdit").serializeArray();
            var id = $("#id").val();
            var name = $("#name").val();
            var description = $("#description").val();
            $.ajax({
                url: "/Permission/Edit",
                type: "post",
                /*
                data: {
                    id: id,
                    name: name,
                    description: description
                },*/
                data:formData,
                dataType: "json",
                success: function (res) {
                    if(res.status=="ok")
                    {
                        //alert("ok");
                        parent.location.reload();//刷新父窗口
                    }
                    else
                    {
                        alert("error");
                    }
                },
                error: function () { alert("请求出错"); }
            });
        };
        $(function(){
            $("#btnSave").click(saveAjax);
        });
    </script>
}